﻿@model QizSession
@{
    var PreviewOnly = (bool)TempData["PreviewOnly"];    //ViewBag.ForceEdit != true && "True".Equals(Request["PreviewOnly"], StringComparison.CurrentCultureIgnoreCase);
}
<div>
    <table class="width col4" style="width: 100%;">
        @if (ViewBag.ForceEdit == true)
        {
            <tr>
                <td colspan="3" class="PageTip">
                    <h3 class="error">部分内容填写不正确，例如必填项未填写或错误的指标值。请修改后重新提交。</h3>
                    <script language="javascript" type="text/javascript">
                        $(function () {
                            alert("部分内容填写不正确，例如必填项未填写或错误的指标值。请修改后重新提交。");
                        });
                    </script>
                    @Html.ValidationSummary()
                </td>
            </tr>
        }
        @if (PreviewOnly)
        {
            bool hastixing = false;

            if (Model.SessionAutoEvaluation == "异常" && !string.IsNullOrEmpty(Model.QizSubject.DescIfBad))
            {
                var devQizs = Model.QizSessionDetails.Where(detail => detail.QizSubjectDefine.IsAllowInMobile &&
                    detail.ValueAutoEvaluation == "异常");
                if (devQizs != null && devQizs.Count() > 0)
                {
            <tr>
                <td colspan="3" class="PageTip" style="font-size: 11pt;">
                    @*<div id="ctrl-deviant" class="error-title">
                        异常指标汇总
                    </div>
                    <div id="block-deviant" class="validation-summary-errors">
                        <ol>
                            @foreach (var QsdItem in devQizs)
                            {
                                @Html.Partial("QsdRenders/QizDeviants", QsdItem)
                                if (QsdItem.QizSubjectDefine.ChildSubjDefs.Count > 0)
                                {
                                    var qsdgps = Model.QizSessionDetails.Where(v => QsdItem.QizSubjectDefine.ChildSubjDefs.Contains(v.QizSubjectDefine))
                                        .OrderBy(v => v.QizSubjectDefine.SortIdx).GroupBy(v => v.QizSubjectDefine.ParentSubjDefVals);
                                    foreach (var gp in qsdgps)
                                    {
                                        foreach(var g in gp)
                                        {
                                        @Html.Partial("QsdRenders/QizDeviants", g)
                                        }
                                    }
                                }
                            }
                        </ol>
                    </div>*@

                    <div class="warnning-block" data-role="collapsible" data-collapsed="false" data-inset="false" data-corners="false">
                        <h2>异常指标汇总</h2>
                        <ol>
                            @foreach (var QsdItem in devQizs)
                            {
                                @Html.Partial("QsdRenders/QizDeviants", QsdItem)
                                if (QsdItem.QizSubjectDefine.ChildSubjDefs.Count > 0)
                                {
                                    var qsdgps = Model.QizSessionDetails.Where(v => QsdItem.QizSubjectDefine.ChildSubjDefs.Contains(v.QizSubjectDefine))
                                        .OrderBy(v => v.QizSubjectDefine.SortIdx).GroupBy(v => v.QizSubjectDefine.ParentSubjDefVals);
                                    foreach (var gp in qsdgps)
                                    {
                                        foreach (var g in gp)
                                        {
                                @Html.Partial("QsdRenders/QizDeviants", g)
                                        }
                                    }
                                }
                            }
                        </ol>
                    </div>
                </td>
            </tr> 
                }
                hastixing = true;
                        
            <tr>
                <td colspan="3" class="PageTip" style="font-size: 11pt;">
                    @*<div id="ctrl-descifbad" class="error-title">
                        随访异常常规建议
                    </div>
                    <div id="block-descifbad" class="validation-summary-errors" style="padding: 10px; font-size: 1em; font-weight: normal;">
                        @Html.Raw(Model.QizSubject.DescIfBad.Replace("\r", "<br/>"))
                    </div>*@
                    <div class="warnning-block" data-role="collapsible" data-inset="false" data-corners="false">
                        <h2>随访异常常规建议</h2>
                        <div class="validation-summary-errors">
                            @Html.Raw(Model.QizSubject.DescIfBad.Replace("\r", "<br/>"))
                        </div>
                    </div>
                </td>
            </tr>                
            }

            if (Model.SessionAutoEvaluation != "异常" && !string.IsNullOrEmpty(Model.QizSubject.DescIfFine))
            {
                hastixing = true;
                        
            <tr>
                <td colspan="3" class="PageTip">
                    @*<div id="ctrl-desciffine" class="error-title" style="font-size: 1.2em;">
                        随访常规建议
                    </div>
                    <div id="block-desciffine" class="validation-summary-errors" style="padding: 10px; font-size: 1em; font-weight: normal;">
                        @Html.Raw(Model.QizSubject.DescIfFine.Replace("\r", "<br/>"))
                    </div>*@
                    <div class="warnning-block" data-role="collapsible" data-inset="false" data-corners="false">
                        <h2>随访常规建议</h2>
                        <div class="validation-summary-errors">
                            @Html.Raw(Model.QizSubject.DescIfFine.Replace("\r", "<br/>"))
                        </div>
                    </div>
                </td>
            </tr>                        
            }
@*<tr>
                        <td colspan="3" class="PageTip">
                            <div id="ctrl-note" class="error-title" style="font-size: 1.2em;">
                                注意事项
                            </div>
                            <div id="block-note" class="validation-summary-errors" style="padding: 10px; font-size: 1em; font-weight: normal;">
                                @Model.QizSubject.DescForRecuper
                            </div>
                        </td>
                    </tr>*@
            if (hastixing)
            {
            <script language="javascript" type="text/javascript">
                $(function () {
                    alert("我们对您的情况给出了一些常规建议，请查看并采取合适的措施。");
                });
            </script>
            }

        }
        else
        {
            <tr>
                <td colspan="3" class="PageTip">
                    <div id="ctrl-note" class="error-title" style="font-size: 1.2em;">
                        注意事项
                    </div>
                    <div id="block-note" class="validation-summary-errors" style="padding: 10px; font-size: 1em; font-weight: normal;">
                        @Model.QizSubject.DescForRecuper
                    </div>
                </td>
            </tr>   
        }
    </table>
</div>
